<?php

namespace app\index\controller\source;

use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\index\model\UM as UM;
use app\index\service\SourcePurchaseService;
use think\APP;
use think\Request as Request;

/**
 * SourcePurchase 控制器
 * Class SourcePurchase
 * @package app\index\controller\source;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\source\SourcePurchase
 */
class SourcePurchase
{
    // 请求参数
    private Request $request;

    // service
    private SourcePurchaseService $service;

    public function __construct(Request $request, SourcePurchaseService $sourcePurchaseService)
    {
        $this->request = $request;
        $this->service = $sourcePurchaseService;
    }
    /**
     * 案源-（真实拨号）
     * @param UM $user
     * @return ApiResponse
     * @url /source/source_purchase/save
     */
    public function save(UM $user): ApiResponse
    {
        $request     = $this->request;

        $data = $this->service->add($user, $request->param());

        return ApiResponse::success($data);
    }

}
